package com.zust.data.util.senly;

import org.apache.commons.lang.StringUtils;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class MobileValidate {

	/**
	 * 手机号码输入时只支持： 数字和,、，-——
	 *
	 * @param mobile
	 * @return
	 */
	public static  boolean matches(String mobile){
		if (StringUtils.isBlank(mobile)) {
			return true;
		}
		Pattern p = Pattern.compile("^[0-9,、，\\-——\\x22]+$");
		boolean flag = true;

		char[] charArray = mobile.toCharArray();
		for (char c : charArray) {
			String s = c + "";
			Matcher m = p.matcher(s);
			if(!m.matches()){
				flag = false;
				break;
			}
		}

		return flag;
	}
}